﻿using AutoMapper;
using MediatR;
using MyMES.Domain.yjb;
using MyMES.Error;
using MyMES.Infrastructure.Interface;
using MyMES.Read.API.Application.Commends.settingCommand;
using MyMES.Read.API.FileNlog;

namespace MyMES.Read.API.Application.CommendHandlers.settingCommand
{
    public class ShowGttCommandHandlers : IRequestHandler<ShowGttCommand, APIPaging<List<ProductionTasks>>>
    {
        private readonly IBaseRepository<ProductionTasks> accreop;
        private readonly Nolgs nlogselvse;
        private readonly IMapper mapper;

        public ShowGttCommandHandlers(IBaseRepository<ProductionTasks> accreop, Nolgs nlogselvse)
        {
            this.accreop = accreop;
            this.nlogselvse = nlogselvse;
            this.mapper = mapper;
        }
        /// <summary>
        /// 甘特图显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<APIPaging<List<ProductionTasks>>> Handle(ShowGttCommand request, CancellationToken cancellationToken)
        {
           
            try
            {
                APIPaging<List<ProductionTasks>> result = new APIPaging<List<ProductionTasks>>();
                result.Code = APIEnum.查询失败;
                result.Msg = "查询成功";
                string sql = "select * from ProductionTasks where IsDelete=false ORDER BY ProductionTaskId DESC";

                var list = await accreop.SelectAsync(sql);
                result.data = list;
                return result;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
